package com.cmti.skeleton.dao.mapper;

import org.apache.ibatis.jdbc.SQL;

import com.cmti.skeleton.entity.SysDict;

public class SysDictSqlProvider {

    public String insertSelective(SysDict record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("sys_dict");
        
        if (record.getCategory() != null) {
            sql.VALUES("CATEGORY", "#{category,jdbcType=VARCHAR}");
        }
        
        if (record.getSubCategory() != null) {
            sql.VALUES("SUB_CATEGORY", "#{subCategory,jdbcType=VARCHAR}");
        }
        
        if (record.getSortIndex() != null) {
            sql.VALUES("SORT_INDEX", "#{sortIndex,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("NAME", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getValue() != null) {
            sql.VALUES("VALUE", "#{value,jdbcType=VARCHAR}");
        }
        
        if (record.getpCategory() != null) {
            sql.VALUES("P_CATEGORY", "#{pCategory,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.VALUES("VALID", "#{valid,jdbcType=INTEGER}");
        }
        
        if (record.getNote() != null) {
            sql.VALUES("NOTE", "#{note,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(SysDict record) {
        SQL sql = new SQL();
        sql.UPDATE("sys_dict");
        
        if (record.getCategory() != null) {
            sql.SET("CATEGORY = #{category,jdbcType=VARCHAR}");
        }
        
        if (record.getSubCategory() != null) {
            sql.SET("SUB_CATEGORY = #{subCategory,jdbcType=VARCHAR}");
        }
        
        if (record.getSortIndex() != null) {
            sql.SET("SORT_INDEX = #{sortIndex,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.SET("NAME = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getValue() != null) {
            sql.SET("VALUE = #{value,jdbcType=VARCHAR}");
        }
        
        if (record.getpCategory() != null) {
            sql.SET("P_CATEGORY = #{pCategory,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.SET("VALID = #{valid,jdbcType=INTEGER}");
        }
        
        if (record.getNote() != null) {
            sql.SET("NOTE = #{note,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("ID = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}